package com.ruoyi;

import org.junit.Test;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class DateGenerator {
    public static List<String> generateDates(int year, int month) {
        List<String> dates = new ArrayList<>();
        // 构建日期格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        // 获取该月份的第一天
        LocalDate startDate = LocalDate.of(year, month, 1);
        // 获取该月份的最后一天
        LocalDate endDate = startDate.plusMonths(1).minusDays(1);
        // 生成每一天的日期，并加入到列表中
        while (!startDate.isAfter(endDate)) {
            dates.add(startDate.format(formatter));
            startDate = startDate.plusDays(1);
        }
        return dates;
    }

    public static void main(String[] args) {
        int year = 2024; // 假设年份为2024
        int month = 3;   // 假设月份为3月
        List<String> dates = generateDates(year, month);

    }
}

